package com.bhs.sansonglogistics.ui.quality;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.viewpager2.widget.ViewPager2;
import android.widget.TextView;
import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.base.BaseFragment;
import com.bhs.sansonglogistics.ui.home.FragmentAdapter;
import com.bhs.sansonglogistics.view.SelectedFont2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import java.util.ArrayList;

/**
 * 充值记录
 */
public class VoucherListActivity extends BaseActivity {

    private TabLayout mTabLayout;
    private ViewPager2 mViewPage;

    @Override
    public int initLayout() {
        return R.layout.activity_voucher_list;
    }

    @Override
    public void initView() {
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText("充值记录");
        mTabLayout = findViewById(R.id.tabLayout);
        mViewPage = findViewById(R.id.view_page);
    }


    @Override
    public void initData() {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        //tab切换时候的字体设置
        mTabLayout.addOnTabSelectedListener(new SelectedFont2(mActivity));
        ArrayList<BaseFragment> fragments = new ArrayList<>();
        fragments.add(VoucherListFragment.newInstance("0"));
        fragments.add(VoucherListFragment.newInstance("1,2,3,4"));

        mViewPage.setOffscreenPageLimit(fragments.size());
        mViewPage.setAdapter(new FragmentAdapter(this, fragments));
        new TabLayoutMediator(mTabLayout, mViewPage, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(position == 0 ? "充值记录" : "退款记录");
            }
        }).attach();
    }

}